<!--
 * @LastEditors: 杜康
 * @LastEditTime: 2021-09-14 13:06:25
-->
<!DOCTYPE html>
<html lang="en">

<head>
  <meta charset="UTF-8">
  <meta http-equiv="X-UA-Compatible" content="IE=edge">
  <meta name="viewport" content="width=device-width, initial-scale=1.0">
  <title>可从外部关闭的下拉菜单</title>
  <link rel="stylesheet" href="style.css">
</head>

<body>
  <div id="app">
    <div class="main" v-clickoutside.esc="handleClose">
      <!-- <div class="main" v-clickoutside="handleClose"> -->
      <button @click="show = !show">点击显示下拉菜单</button>
      <div class="dropdown" v-show="show">
        <p>下拉框的内容，点击外面区域可以关闭</p>
      </div>
    </div>
  </div>
  <script src="https://unpkg.com/vue/dist/vue.min.js"></script>
  <script src="clickoutside.js"></script>
  <script src="index.js"></script>
</body>

</html>